package com.dinian.demeter.controller;

import com.dinian.demeter.domain.Fault;
import com.dinian.demeter.service.FaultService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Slf4j
@Controller
public class HelloController {

    @Autowired
    private FaultService faultService;

    @RequestMapping("/hello")
    public String hello(Model model, @RequestParam(value="name", required=false, defaultValue="World") String name) {
        model.addAttribute("name", name);
        return "hello";
    }

    /**
     * 测试table
     * @return
     */
    /*@RequestMapping(value="/tableInit",produces="html/text;charset=UTF-8")*/
    @RequestMapping(value="/tableInit1")
    @ResponseBody
    public List<Fault> table() {
        List<Fault> faultList = faultService.findFaultByUserId("1");
        log.info("faultList = {}",faultList);
        return faultList;
    }
}
